package calorie.com.calorie.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.response.AssertInfomationResponce;
import retrofit2.Call;
import retrofit2.Response;

public class GetAssetsContact {

    public static class GetAssetsPresent extends BasePresent<IgetAssets> {
        public void getAssets(Context context) {
            ApiService service = ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            service.getUserAssets(userId).enqueue(new NetCallBack<AssertInfomationResponce>() {
                @Override
                public void onSuccess(Call<AssertInfomationResponce> call, Response<AssertInfomationResponce> response) {
                  if (getView()!=null){
                      getView().getAssetsResult(response);
                  }
                }

                @Override
                public void onFailed() {

                }
            });
        }
    }

    public interface IgetAssets extends IBaseView {
        void getAssetsResult(Response<AssertInfomationResponce> response);
    }

}
